package com.heima.金额转换;

import java.util.Scanner;

public class Jinezhuanhuan {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int money=0;
        while(true){
            System.out.println("请输入金额：");
            money=sc.nextInt();
            if(money>=0&&money<=9999999){
                break;
            }else{
                System.out.println("金额无效，请重新输入：");
            }
        }
        String moneyStr="";
        while(true){
            //从右往左获取数字
            int ge=money%10;
            String capitalNumber = getCapitalNumber(ge);
            moneyStr=capitalNumber+moneyStr;

            money=money/10;
            if(money==0){
                break;
            }
        }
        //补零
        int count=7-moneyStr.length();
        for(int i=0;i<count;i++){
            moneyStr="零"+moneyStr;
        }
        //System.out.println(moneyStr);
        //插入单位
        String[] arr={"佰","拾","万","仟","佰","拾","元"};
        String result="";
        for(int i=0;i<moneyStr.length();i++){
            char c=moneyStr.charAt(i);//便利输入的数字的每一位
            result=result+c+arr[i];
        }
        System.out.println(result);
    }
    //定义一个方法，把数字变成大写中文
    public static String getCapitalNumber(int number) {
        String[] arr = {"零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"};
        return arr[number];

    }
}
